package com.boc.ewr.business.service.impl;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.boc.ewr.business.entity.LineAccessList;
import com.boc.ewr.business.mapper.LineAccessListMapper;
import com.boc.ewr.business.service.ILineAccessListService;
import com.boc.ewr.util.file.enumeration.LineCheckContentEnum;
import org.jeecg.common.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 《条线考核数据汇总》
 * @Author: jeecg-boot
 * @Date:   2023-04-20
 * @Version: V1.0
 */
@Service
public class LineAccessListServiceImpl extends ServiceImpl<LineAccessListMapper, LineAccessList> implements ILineAccessListService {

    @Autowired
    RedisUtil redisUtil;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean createInfo() {
        List<LineAccessList> result = new ArrayList<>();
        /*result.addAll(baseMapper.creatKeyInfo());
        result.addAll(baseMapper.creatNoKeyInfo());
        result.addAll(baseMapper.creatSigningInfo());
        result.addAll(baseMapper.creatA1BillInfo());
        result.addAll(baseMapper.creatA2BillInfo());
        result.addAll(baseMapper.creatA3BillInfo());

        result.addAll(baseMapper.creatRiskInfo());

        //TODO 季度报告，截至日期设置在配置缓存redis中？
        String deadline = redisUtil.get("dealine") != null ? redisUtil.get("dealine").toString() : DateUtil.now();

        result.addAll(baseMapper.creatCheckInfo(deadline));
        result.addAll(baseMapper.creatReportInfo(deadline));*/
        return saveBatch(result);
    }

    @Override
    public List<LineAccessList> queryLineAccess(LineCheckContentEnum lineCheckEnum){
        List<LineAccessList> result = new ArrayList<>();
//        switch (lineCheckEnum){
//            //对账指标考核
//            case KEYBILL:
//                result.addAll(baseMapper.creatKeyInfo());
//                break;
//            case RECEIPTRATE:
//                result.addAll(baseMapper.creatNoKeyInfo());
//                break;
//            case TIMELINESSRATE:
//                result.addAll(baseMapper.creatSigningInfo());
//                break;
//            case COMPLETIONRATE:
//                result.addAll(baseMapper.creatA1BillInfo());
//                result.addAll(baseMapper.creatA2BillInfo());
//                result.addAll(baseMapper.creatA3BillInfo());
//                break;
//            //条线履职
//            //季度报告
//            case REPORT:
//                String deadline = redisUtil.get("dealine") != null ? redisUtil.get("dealine").toString() : DateUtil.now();
//                result.addAll(baseMapper.creatReportInfo(deadline));
//                break;
//            case FEEDBACK:
//                result.addAll(baseMapper.creatRiskInfo());
//                break;
//            case SPOTCHECK:
//                String endline = redisUtil.get("dealine") != null ? redisUtil.get("dealine").toString() : DateUtil.now();
//                result.addAll(baseMapper.creatCheckInfo(endline));
//                break;
//
//        }
        return result;
    }
}
